package alo.p19;

/**
 * @ClassName BestGame
 * @Description 最优游戏策略
 * @Author Fanxc
 * @DATE 2021/3/15 19:33
 * @Version 1.0
 */
public class BestGame {
    void bestGame(int[] A,int n){
        int[][] L=new int[n][n];
        for (int i = 0; i < n-1; i++) {
            L[i][i+1]=Math.max(A[i],A[i+1]);
        }
        for (int i = 0; i < n-1; i++) {
            for (int j = 2; j < n-1; j++) {
                L[i][j]=Math.max(Math.min(L[i+1][j-1],L[i+2][j])+A[i],Math.min(L[i][j-2],L[i+1][j-1])+A[j]);
            }
        }
    }
}
